package cn.com.tarotframework.boot.mybatis;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * copyright (C), 2022, 塔罗牌基础架构
 * @program: tarot-mysql-spring-boot-starter
 * @description: MyBatis plus 拦截处理转换类
 * @author: xincan
 * @date: 2022/05/20 16:44
 * @version: 0.0.1-SNAPSHOT
 */
@Component
public class MyBatisMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createUserId", String.class , "1285759156342562818");
        this.strictInsertFill(metaObject, "createTime", LocalDateTime.class , LocalDateTime.now());
        this.strictInsertFill(metaObject, "editUserId", String.class , "1285759156342562818");
        this.strictInsertFill(metaObject, "editTime", LocalDateTime.class , LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "editUserId", String.class , "1285759156342562818");
        this.strictUpdateFill(metaObject, "editTime", LocalDateTime.class , LocalDateTime.now());
    }

}
